﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "IMepElement.h"
#include "IExternalData.h"
#include "WeakPtr.h"
#include "ElementCreationOptions.h"
#include "UniIdentity.h"

namespace gcmp
{
    class IInstance;
}

namespace gmep
{
    ///\brief：创建机电构件输入参数基类
    struct MepInstanceInput
    {
        MepInstanceInput() : Document(nullptr), CanBeShared(true), Visible(true), BaseOffset(0.0), CreationOption(gcmp::ElementCreationOptions::Normal)
        {
        }
        explicit MepInstanceInput(gcmp::IDocument *pDoc, const gcmp::ElementId &typeId, const gcmp::ElementId &assocPlaneId, const gcmp::UniIdentity &catUid) : 
        Document(pDoc), InstanceTypeId(typeId), AssociatedPlaneId(assocPlaneId), CategoryUid(catUid),
        CreationOption(gcmp::ElementCreationOptions::Normal), CanBeShared(true), Visible(true), BaseOffset(0.0), Position(gcmp::Vector3d::Zero)
        {
        }
        virtual ~MepInstanceInput() {}

        mutable gcmp::WeakPtr<gcmp::IDocument> Document;   ///文档指针
        gcmp::ElementId InstanceTypeId;              ///类型Id
        gcmp::ElementId AssociatedPlaneId;           ///关联平面Id（通常为标高)
        gcmp::ElementCreationOptions CreationOption; ///元素创建状态类型
        bool CanBeShared;                            ///true表示图形可以共享，否则不允许共享
        bool Visible;                                ///可见性，true表示创建出对象为可见，否则为不可见。
        gcmp::UniIdentity CategoryUid;               ///构件类别Uid
        gcmp::Vector3d Position;                     ///布置位置
        double BaseOffset;                           ///标高偏移量
    };

    class IMepInstanceType;

    ///brief:机电实例类
    class GMEP_MODEL_BASE_INTERFACE_EXPORT IMepInstance : public gcmp::IExternalData, public IMepElement
    {
        DEFINE_CAST_DERIVED2(gmep::IMepInstance, gcmp::IExternalData, gmep::IMepElement)
    public:
        virtual ~IMepInstance() {}

    public:
        /// \brief 得到gcmp平台的元素指针
        /// \return gcmp平台的元素指针
        virtual const gcmp::IElement *GetElement() const override;

        /// \brief 得到gcmp平台的元素指针
        /// \return gcmp平台的元素指针
        virtual gcmp::IElement *GetElement() override;

        /// \brief 得到gcmp平台的实例类型指针
        /// \return gcmp平台的实例类型指针
        const gcmp::IInstance *GetInstance() const;

        /// \brief 得到gcmp平台的实例类型指针
        /// \return gcmp平台的实例类型指针
        gcmp::IInstance *GetInstance();

        /// \brief 得到机电实例对应的类型指针
        /// \return 机电实例对应的类型指针
        const gmep::IMepInstanceType *GetMepInstanceType() const;

        /// \brief 得到机电实例对应的类型指针
        /// \return 机电实例对应的类型指针
        gmep::IMepInstanceType *GetMepInstanceType();

        /// \brief 获取机电系统对象Id
        /// \return 机电系统对象Id
        virtual gcmp::ElementId GetMepSystemId() const = 0;
    };
}
